import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/** note: submenu only apppear when children.length>=1
*   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
**/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  { path: '/404', component: _import('errorPage/404'), hidden: true },
  { path: '/401', component: _import('errorPage/401'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      meta: { title: 'dashboard', icon: 'homePage', noCache: true }
    }]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/organizationManagement',
    component: Layout,
    redirect: 'noredirect',
    name: 'organizationManagement',
    alwaysShow: true,
    meta: {
      title: 'organizationManagement',
      icon: 'organization',
      roles: ['010100']
    },
    children: [
      { path: 'organization', component: _import('organizationManagement/organization'), name: 'organization', meta: { title: 'organization', noCache: true, roles: ['600000'] }},
      { path: 'personnelFile', component: _import('organizationManagement/personnelFile'), name: 'personnelFile', meta: { title: 'personnelFile', noCache: true, roles: ['020100'] }},
      { path: 'blackList', component: _import('organizationManagement/blackList'), name: 'blackList', meta: { title: 'blackList', noCache: true, roles: ['020900'] }}
    ]
  },
  {
    path: '/operatingManagement',
    component: Layout,
    redirect: 'noredirect',
    name: 'operatingManagement',
    alwaysShow: true,
    meta: {
      title: 'operatingManagement',
      icon: 'operatingManagement',
      roles: ['530000']
    },
    children: [
      { path: 'parkingflowRecord', component: _import('operatingManagement/parkingflowRecord'), name: 'parkingflowRecord', meta: { title: 'parkingflowRecord', noCache: true, roles: ['040700'] }},
      { path: 'electronicPyStatistics', component: _import('operatingManagement/electronicPyStatistics'), name: 'electronicPyStatistics', meta: { title: 'electronicPyStatistics', noCache: true, roles: ['110300'] }},
      { path: 'chargeStandard', component: _import('operatingManagement/chargeStandard'), name: 'chargeStandard', meta: { title: 'chargeStandard', noCache: true, roles: [''] }}
    ]
  },
  {
    path: '/assessmentManagement',
    component: Layout,
    redirect: 'noredirect',
    name: 'assessmentManagement',
    alwaysShow: true,
    meta: {
      title: 'assessmentManagement',
      icon: 'assessmentManagement',
      roles: ['540000']
    },
    children: [
      { path: 'peopleFeeStatistics', component: _import('assessmentManagement/peopleFeeStatistics'), name: 'peopleFeeStatistics', meta: { title: 'peopleFeeStatistics', noCache: true, roles: ['110400'] }},
      { path: 'lotFeeStatistics', component: _import('assessmentManagement/lotFeeStatistics'), name: 'lotFeeStatistics', meta: { title: 'lotFeeStatistics', noCache: true, roles: ['540100'] }}
    ]
  },
  {
    path: '/dataMonitoring',
    component: Layout,
    redirect: 'noredirect',
    name: 'dataMonitoring',
    alwaysShow: true,
    meta: {
      title: 'dataMonitoring',
      icon: 'dataMonitoring',
      roles: ['540000']
    },
    children: [
      { path: 'parkingMonitoring', component: _import('dataMonitoring/parkingMonitoring'), name: 'parkingMonitoring', meta: { title: 'parkingMonitoring', noCache: true, roles: ['110400'] }},
      { path: 'tollCollectorMonitoring', component: _import('dataMonitoring/tollCollectorMonitoring'), name: 'tollCollectorMonitoring', meta: { title: 'tollCollectorMonitoring', noCache: true, roles: ['110400'] }}
    ]
  },
  {
    path: '/parkingResourceManagement',
    component: Layout,
    redirect: 'noredirect',
    name: 'parkingResourceManagement',
    alwaysShow: true,
    meta: {
      title: 'parkingResourceManagement',
      icon: 'parkingResourceManagement',
      roles: ['540000']
    },
    children: [
      { path: 'tollSectionManagement', component: _import('parkingResourceManagement/tollSectionManagement'), name: 'tollSectionManagement', meta: { title: 'tollSectionManagement', noCache: true, roles: ['110400'] }},
      { path: 'parkingManagement', component: _import('parkingResourceManagement/parkingManagement'), name: 'parkingManagement', meta: { title: 'parkingManagement', noCache: true, roles: ['110400'] }},
      { path: 'parkingSpaceManagement', component: _import('parkingResourceManagement/parkingSpaceManagement'), name: 'parkingSpaceManagement', meta: { title: 'parkingSpaceManagement', noCache: true, roles: ['110400'] }},
      { path: 'tollRoadManagement', component: _import('parkingResourceManagement/tollRoadManagement'), name: 'tollRoadManagement', meta: { title: 'tollRoadManagement', noCache: true, roles: ['110400'] }}
    ]
  },
  {
    path: '/tradeManagement',
    component: Layout,
    redirect: 'noredirect',
    name: 'tradeManagement',
    alwaysShow: true,
    meta: {
      title: 'tradeManagement',
      icon: 'tradeManagement',
      roles: ['540000']
    },
    children: [
      { path: 'doublePayment', component: _import('tradeManagement/doublePayment'), name: 'doublePayment', meta: { title: 'doublePayment', noCache: true, roles: ['110400'] }},
      { path: 'financialDataStatistics', component: _import('tradeManagement/financialDataStatistics'), name: 'financialDataStatistics', meta: { title: 'financialDataStatistics', noCache: true, roles: ['110400'] }},
      { path: 'electronicPaymentDetail', component: _import('tradeManagement/electronicPaymentDetail'), name: 'electronicPaymentDetail', meta: { title: 'electronicPaymentDetail', noCache: true, roles: ['110400'] }},
      { path: 'fnancialDetailsSearch', component: _import('tradeManagement/fnancialDetailsSearch'), name: 'fnancialDetailsSearch', meta: { title: 'fnancialDetailsSearch', noCache: true, roles: ['110400'] }},
      { path: 'financialDailyFlowSearch', component: _import('tradeManagement/financialDailyFlowSearch'), name: 'financialDailyFlowSearch', meta: { title: 'financialDailyFlowSearch', noCache: true, roles: ['110400'] }}
    ]
  },
  {
    path: '/systemManagement',
    component: Layout,
    redirect: 'noredirect',
    name: 'systemManagement',
    alwaysShow: true,
    meta: {
      title: 'systemManagement',
      icon: 'systemManagement',
      roles: ['540000']
    },
    children: [
      { path: 'functionalRolesManagement', component: _import('systemManagement/functionalRolesManagement'), name: 'functionalRolesManagement', meta: { title: 'functionalRolesManagement', noCache: true, roles: ['110400'] }},
      { path: 'dataRoleManagement', component: _import('systemManagement/dataRoleManagement'), name: 'dataRoleManagement', meta: { title: 'dataRoleManagement', noCache: true, roles: ['110400'] }}
    ]
  },
  {
    path: '/statisticalAnalysis',
    component: Layout,
    redirect: 'noredirect',
    name: 'statisticalAnalysis',
    alwaysShow: true,
    meta: {
      title: 'statisticalAnalysis',
      icon: 'statisticalAnalysis',
      roles: ['540000']
    },
    children: [
      { path: 'tollBusinessStatistics', component: _import('statisticalAnalysis/tollBusinessStatistics'), name: 'tollBusinessStatistics', meta: { title: 'tollBusinessStatistics', noCache: true, roles: ['110400'] }}
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
